#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtNetwork>

#include <opencv2/face.hpp>
#include <opencv2/face/facerec.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/objdetect/objdetect.hpp>

#include "aes_tcp/aes_tcp.h"


extern "C"{

#include "v4l2_c/v4l2.h"

}

using namespace cv;
using namespace cv::face;

namespace Ui {
class MainWindow;
}

class Thread_photo: public QThread
{

     Q_OBJECT

public:
    void run();
    QString name; //添加一个 name 对象

    QImage image_my;
    int get_image_flag = 0;

    CascadeClassifier cascade;
    pass_data pd;
    Ptr<FaceRecognizer> model;

    int Predict_labe(Mat src_image);
    QString predict(void);

    Mat QImage2cvMat(QImage image);
    QImage cvMat2QImage(const cv::Mat& mat);

signals:
    void face_ok(QString str);

};


class MainWindow : public QMainWindow
{
    Q_OBJECT

public:

    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    aes_tcp *my_tcp = new aes_tcp;
    QTimer * timer_4s = new QTimer;

    Thread_photo * cv_face_thread = new Thread_photo;

    QUdpSocket *local_udp;

    int f_id=0;

    void do_cmd(QByteArray cmd);

     uint32_t data_point = 0;

    QTimer *face_timer =new QTimer;

    void nrf_send(void * data, uint16_t size);

    void send_photo();

private slots:
    void do_local_udp();
    void do_face_ok(QString str);
    void read_tcp(QByteArray b_data);
    void sensor_enable();

private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H
